import java.util.Arrays;

public class sort {
    public static int[] sortOdd(int[] array) {
        int[] arr = new int[array.length];
        int flag = 0;
        int flag2 = array.length - 1;

        for (int i = 0; i < array.length ; i++) {
            if(array[i] % 2 == 1){
                arr[flag] =  array[i];
                flag ++;
            }else{
                arr[flag2] = array[i];
                flag2 --;
            }
        }
        return arr;
    }
    public static void main(String[] args) {
        int[] array = new int[]{1,2,3,4,5,6};
        int[] arr = sortOdd(array);
        System.out.println(Arrays.toString(arr));
    }
}
